#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>
#include <assert.h>

char* my_strncat(char* distination, const char* source, size_t num)
{
	char* ret = distination;
	int i = 0;

	assert(distination != NULL);
	assert(source != NULL);

	while (*distination != '\0')
	{
		distination++;
	}

	for (i = 0; i < num; i++)
	{
		if (*source != '\0')
		{
			*distination = *source;
			distination++;
			source++;
		}
		else
		{
			break;
		}
	}

	*distination = '\0';

	return ret;
}

int main()
{
	char str1[20] = "zhao";
	char str2[20] = "Carl";

	char* p = my_strncat(str1, str2, 3);

	printf("%s\n", p);

	return 0;
}
